<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>考勤查询</title>
<link href="css/background.css" rel="stylesheet" type="text/css" />
<link href="css/table.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/openwindow.js"></script>
<script src="js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
<script type="text/javascript">
	function taskSave(){
		var url="taskSave.action";
		openWindow(url,804,604);
	}
	
	function taskNew(taskId){
		var url="taskNew.action?taskId="+taskId;
		openWindow(url,804,604);
	}
	
	function taskNewEnd(taskId){
		var url="taskNewEnd.action?taskId="+taskId;
		openWindow(url,804,604);
	}
	
	function taskUpdate(taskId){
		var url="taskUpdate.action?taskId="+taskId;
		openWindow(url,804,604);
	}
	

function searchByDay(time,val){
	 if(val=='2'){
	window.location.href="attendByMonth.action?status="+val;
	}else{
		window.location.href="taskList.action?status="+val;
	}
}
$(function(){
	var status=$("#status").val();
	var arra=document.getElementsByName("queryTimeType");
	for(var i=0;i<arra.length;i++){
		if(status==arra[i].value){
			arra[i].checked=true;
			break;
		}
	}
});

function dateSearch(val){
	var time=$("#time").val();
	var date= new Date(Date.parse(time.replace(/-/g,   "/")));
	var date2;
	if(val=="+"){
		 date2=new Date(date.getFullYear(),date.getMonth(),date.getDate()+1);
	}else{
		 date2=new Date(date.getFullYear(),date.getMonth(),date.getDate()-1);
	}
	time=date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
	window.location.href="taskListByDay.action?time="+time+"&status=1";
}

function clickYear(val){
	var time=$("#time").val();
	var date= new Date(Date.parse(time.replace(/-/g,   "/")));
	var date2;
	if(val=="+"){
		 date2=new Date(date.getFullYear()+1,date.getMonth(),1);
	}else{
		 date2=new Date(date.getFullYear()-1,date.getMonth(),1);
	}
	time=date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
		 window.location.href="attendByMonth.action?time="+time+"&status=2";
			
}


function clickMonth(val){
	var time=$("#time").val();
	var date= new Date(Date.parse(time.replace(/-/g,   "/")));
	var date2;
	if(val=="+"){
		 date2=new Date(date.getFullYear(),date.getMonth()+1,1);
	}else{
		 date2=new Date(date.getFullYear(),date.getMonth()-1,1);
	}
	time=date2.getFullYear()+"-"+(date2.getMonth()+1)+"-"+date2.getDate();
		 window.location.href="attendByMonth.action?time="+time+"&status=2";
}

$(function(){
      $("#tabllist #row:odd").addClass("reigh_list3"); //even odd 为jquery的方法，even为偶数，odd为奇数。特别注意：索引从0开始，所以第一行是偶数！
	  $("#tabllist #row:even").addClass("reigh_list4"); 
});

function overStyle(ths){
		ths.className='reigh_list5';
	}
	
function outStyle(ths){
		ths.className=ths.className.replace('reigh_list5','');
     	$("#tabllist #row:odd").addClass("reigh_list3"); //even odd 为jquery的方法，even为偶数，odd为奇数。特别注意：索引从0开始，所以第一行是偶数！
	    $("#tabllist #row:even").addClass("reigh_list4"); 
	}
	
function checkAll(){
	var all=$("#all");
	var checks=$("input[name='ids']");
	if(all.attr("checked")){
		checks.attr("checked","checked");
	}else{
		checks.attr("checked","");
	}
}

function checkodd(){
	var conm=0;
	var all=$("#all");
	var checks=$("input[name='ids']");
	for(i=0;i<checks.length;i++){
		if(checks[i].checked){
			conm++;
		}
	}
	if(conm==checks.length){
		all.attr("checked","checked");
	}else{
		all.attr("checked","");
	}
}
</script>
</head>
<body>
<input type="hidden" id="time" value="${time}">
<input type="hidden" id="status" value="${status }">
<input id="year" type="hidden" name="year" value="${date.year}">
  <input id="month" type="hidden" name="month" value="${date.month}">
<table  border="0" cellpadding="0" cellspacing="0" width="100%">
  <tbody>
  <tr>
    <td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
    <td style="background: url('image/wsoa_window_002.gif');"><table border="0" cellpadding="0" cellspacing="0">
      <tbody><tr>
        <td align="center" style="background: url('image/wsoa_window_002.gif');" width="10"><img src="image/center_19.gif"></td>
        <td align="center" style="background: url('image/wsoa_window_002.gif');"></td>
        <td> 个人办公 &gt; 考勤管理 &gt; 考勤记录</td>
        </tr>
    </tbody>
    </table></td>
    <td style="background: url('image/wsoa_window_002.gif');" width="1"></td>
  </tr>
  <tr>
    <td style="background: url('image/wsoa_window_010.gif');"  width="1">&nbsp;</td>
    <td>
    
		<table align="center" height="15" width="100%"><tbody><tr><td></td></tr></tbody></table>
	<table align="center" border="0" cellpadding="0" cellspacing="0" width="100%">
		<tbody><tr>
			<td align="left" width="65%;"><span>	
			
			
			
			</span>
			</td>
			<td align="right" background="taskCx_files/wsoa_window_015.htm" width="40%">
			<span id="errorId"></span>&nbsp;&nbsp;			
			</td>
		</tr>
	</tbody></table>
<!-- 按周 -->
<table width="100%">
<tbody><tr>
<td style="vertical-align: top;" width="72%">
<table width="100%">
<tr>
<td align="center">
  <a href="javascript:clickYear('-');" id="previousyear"> << </a> <span>${date.year+1900}年</span> <a href="javascript:clickYear('+');" id="nextyear"> >> </a>
  <a href="javascript:clickMonth('-');" id="previousmonth">  << </a><span>${date.month+1}月</span><a href="javascript:clickMonth('+');" id="nextmonth"> >> </a></td>
</tr>
</table>
<tbody><tr>
<td style="vertical-align: top;" width="72%"><br><table style="margin-top: 10px" id="tabllist" class="righ_list" frame="box" cellspacing="1" cellpadding="0" width="100%"  border="0">
<tr class="reigh_list2">
	<td>星期日</td> <td>星期一</td> <td>星期二</td> <td>星期三</td> <td>星期四</td> <td>星期五</td> <td>星期六</td>
</tr>
<c:forEach items="${days}" var="week" >
  	<tr id="row" >
  		<c:forEach items="${week}" var="day">
  		<td style="vertical-align: top; text-align: center" height="50px" ><span <c:if test="${day.day==0||day.day==6}">style="color: #ff0000" </c:if> >${day.date}<c:if test="${day!=null}">日</span></c:if><br>
  		<c:set var="date"><fmt:formatDate value="${day}" pattern="yyyy-MM-dd" /></c:set>
		<c:forEach items="${oattendanceHolidayList}" var="oah">
  						<c:set var="holiday"><fmt:formatDate value="${oah.dayoff}"  pattern="yyyy-MM-dd" /></c:set>
  					<c:if test="${date==holiday}"> 
  						<table align="center"> <tr align="center"> <td align="center"><span style="color: #ff3366">${fn:substring(oah.state,0,5)}</span></td></tr></table>
  					</c:if>
  					</c:forEach>
		<c:forEach items="${oarList}" var="oar">
		<c:set var="time"><fmt:formatDate value="${oar[6]}" pattern="yyyy-MM-dd" /></c:set>
			
  			<c:if test="${time==date}">
  				<table width="90">
  					
  					<c:if test="${oar[0]!=null}">	<tr> <td width="50">上午签到</td><td width="30">${oar[0]}</td></tr></c:if>
  					<c:if test="${oar[1]!=null}">	<tr> <td>上午签退</td><td>${oar[1]}</td></tr></c:if>
  					<c:if test="${oar[2]!=null}">	<tr> <td>下午签到</td><td>${oar[2]}</td></tr></c:if>
  					<c:if test="${oar[3]!=null}">	<tr> <td>下午签退</td><td>${oar[3]}</td></tr></c:if>
  					<c:if test="${oar[4]!=null}">	<tr> <td>晚上签到</td><td>${oar[4]}</td></tr></c:if>
  					<c:if test="${oar[5]!=null}">	<tr> <td>晚上签退</td><td>${oar[5]}</td></tr></c:if>
  								
  				</table>
  			</c:if>			
  		</c:forEach>
  		</td> 
  		</c:forEach>
  	</tr>
  	</c:forEach>

</table>
<!-- 按月 -->
</td>
<td style="vertical-align: top;" align="right" width="220px">
<br><br><br><br><br><br>
	<div id="div1" style="width: 200px"></div>
		<script>
			var time=$("#time").val();
			WdatePicker({eCont:'div1',onpicked:function(dp){
			window.location.href="attendByMonth.action?time="+dp.cal.getDateStr()+"&status=2";
			}})
			</script>
</td>
</tr>
</tbody>
</table>

     </td>
<td style="background: url('image/wsoa_window_006.gif');"  width="1">&nbsp;</td></tr>
  <tr>
    <td height="1" width="1"><img src="image/wsoa_window_009.gif" height="16" width="14"></td>
    <td style="background: url('image/wsoa_window_008.gif');" height="1"></td>
    <td height="1" width="1"><img src="image/wsoa_window_007.gif" height="16" width="12"></td>
  </tr>
</tbody>
</table>
</body>
</html>